Conversation
…n be flagged by a san check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1524 I think.
Reproducing 1524 is a hassle because it happens only on Windows and only under SAN checking.
The problem is a memcpy where C++ run-time SAN checking says both pointers (input and output) are passed as null. This was in a user's code, specifically in their package vignette (is that why it was run with SAN checking by CRAN?).
From studying the situation, I think the "problem" (i.e. not a problem) could occur from a memcpy of size 0 (which is harmless anyway). I can't see a way that our generated code would pass uninitialized NimArr objects in a real (not size 0) situation. If that was happening we'd be seeing crashes. But in a corner case it could pass size 0 objects, and I guess they could be uninitialized but it wouldn't matter, and memcpy would not do anything, but the C++ type expectation is still that the input pointers must not be void (according to what I just read about this). So my change here is to quickly exit if the copying size involved is 0. I'd prefer not to try to check if this actually removes the SAN checking error (because it is harmless and not evident in our own tests or CRAN check results) and just make this change (because it is harmless) and see if it ever comes up again.